package com.hfy.pcberpbackend.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 供应商实体类
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("suppliers")
public class Supplier {
    
    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    
    /**
     * 供应商代码
     */
    @NotBlank(message = "供应商代码不能为空")
    @Size(min = 2, max = 20, message = "供应商代码长度必须在2-20个字符之间")
    @TableField("supplier_code")
    private String supplierCode;
    
    /**
     * 供应商名称
     */
    @NotBlank(message = "供应商名称不能为空")
    @Size(min = 2, max = 50, message = "供应商名称长度必须在2-50个字符之间")
    @TableField("supplier_name")
    private String supplierName;
    
    /**
     * 供应商类型
     */
    @NotBlank(message = "供应商类型不能为空")
    @Pattern(regexp = "^(material|equipment|service|other)$", message = "供应商类型必须是material、equipment、service或other")
    @TableField("supplier_type")
    private String supplierType;
    
    /**
     * 联系人姓名
     */
    @NotBlank(message = "联系人姓名不能为空")
    @Size(min = 2, max = 30, message = "联系人姓名长度必须在2-30个字符之间")
    @TableField("contact_name")
    private String contactName;
    
    /**
     * 联系人电话
     */
    @NotBlank(message = "联系人电话不能为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "联系人电话格式不正确")
    @TableField("contact_phone")
    private String contactPhone;
    
    /**
     * 地址
     */
    @TableField("address")
    private String address;
    
    /**
     * 状态
     */
    @NotBlank(message = "状态不能为空")
    @Pattern(regexp = "^(active|inactive)$", message = "状态必须是active或inactive")
    @TableField("status")
    private String status;
    
    /**
     * 逻辑删除
     */
    @TableLogic
    @TableField("deleted")
    private Integer deleted;
    
    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;
    
    /**
     * 更新时间
     */
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;
} 